<extend name="./Application/Home/View/Layout/application.html"/>
<block name="content">

<div class="slick meun">
    <volist name="galleries" id="gallery">
        <a href="javascript:void(0);"><img class="img-responsive" src="{{$gallery.img}}" alt="图片一" style="width: 354px;height: 222px;"/></a>
    </volist>
</div>

<section class="detail">
    <hgroup class="product">
        <input type="hidden" class="thumb" value="{{$products.thumb}}">
        <input type="hidden" class="product_id" value="{{$products.id}}">
        <h1>{{$products.name}}</h1>
        <h2>¥ {{$products.price}}元</h2>
    </hgroup>
    <p>
        {{$products.description|htmlspecialchars_decode|strip_tags}}
    </p>
</section>

<section class="operate" >
    <a id="btn-buy" href="" data-id="{{$products.id}}">立即购买</a>
    <span id="btn-cart-plus" href="#" data-id="{{$products.id}}">加入购物车</span>
</section>

<!--<a href="{{:U('Cart/cart',['id'=>$products[id]])}}" id="btn-cart" >-->
<!--<i class="fa fa-shopping-cart" ></i><span>1</span></a>-->
</block>
<block name="js">
    <script>
        $(function () {
            //加入购物车
            $('#btn-cart-plus').click(function () {
                $('#btn-cart').fadeIn(400);

                var product_id = $(this).data('id');
                $.post("{{:U('Cart/add')}}",{product_id:product_id},function (info) {
                    if(info.status == 0){
                        alert(info.msg);
                        location.href = "{{:U('Customer/login')}}";
                    }else{
                        alert(info.msg);
                        window.location.reload();
                    }
                })
                return false;
            })

            $('#btn-buy').click(function () {
                //立刻购买
                var product_id = $(this).data('id');
                $.post("{{:U('Cart/add')}}",{product_id:product_id},function (info) {
                    if(info.status == 0){
                        alert(info.msg);
                        location.href = "{{:U('Customer/login')}}";
                    }else{
                        location.href = "{{:U('Order/index')}}";

                    }
                })
            })



        })
    </script>
</block>
